<?php
/**
 * Holds class Singleton
 *
 * @author daantimmer
 *
 * @package Library
 */

/**
 * Singleton class.
 *
 * Can only be used on servers with PHP version 5 > 5.2
 *
 * @author daantimmer
 */
class Singleton{

	private static $instances = array();
	
	protected function __construct(){}

	final protected function __clone(){}

	final public static function instance(){
		$class_name = get_called_class();
		
		if (!isset(self::$instances[$class_name]))
		self::$instances[$class_name] = new $class_name;

		return self::$instances[$class_name];
	}
}